home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / tscript.arc / TSCRIPT.PAS < prev   
Pascal/Delphi Source File  |  1985-08-02  |  41KB  |  1,608 lines

  1. Program Wordprocess;
  2. {$C-,V-,I-}
  3. type
  4.     TempString = string[80];
  5.  
  6. const
  7.   Digits: array[1..10] of char = ('1','2','3','4','5','6','7','8','9','0');
  8.   Positions: array[1..10] of integer = (1,8,18,25,33,39,49,59,67,74);
  9. var
  10.     Keynum, Row, Column, I, MaxRow, ScreenRow, Temp1, Temp2, Temp3,
  11.          TopMargin, LeftMarg, RightMarg, Num, code, Style, Index, NumEnd,
  12.          Position1, Position3, DiskSpace : integer;
  13.     Inkey, SecInkey, Choice, ch : char;
  14.     Words : array[1..500] of TempString;
  15.     Tabset : array[1..80] of boolean;
  16.     TextFile : Text;
  17.     TempWord, FileName, Test, Typeset : TempString;
  18.     Secnum, Row_One, Insertmode, Exit, result, Undermode, Boldmode, Italicmode : boolean;
  19.     dosrec : record
  20.                ax,bx,cx,dx,bp,si,di,ds,es,flags : integer;
  21.              end;
  22.     OurDTA : array [ 1..43 ] of byte;    { Data Transfer Area buffer }
  23.     CurDTAseg,                           { DTA segment before execution }
  24.     CurDTAofs,                           { DTA offset    "        "     }
  25.     OurDTAseg,                           { DTA segment and offset set after }
  26.     OurDTAofs          : integer;        { start of program }
  27.  
  28. procedure Fill_In;
  29. var Temprow, Temp : integer;
  30. begin
  31.    Window(27,6,52,18);
  32.    ClrScr;
  33.    Window(1,2,80,23);
  34.    Temp := Row;
  35.    if ScreenRow>5 then begin
  36.      repeat
  37.         ScreenRow := ScreenRow - 1;
  38.         Row := Row - 1;
  39.      until ScreenRow = 5;
  40.    end;
  41.    if ScreenRow < 5 then begin
  42.       repeat
  43.          ScreenRow := ScreenRow + 1;
  44.          Row := Row + 1;
  45.       until ScreenRow = 5;
  46.    end;
  47.    Temprow := ScreenRow;
  48.    for i := 1 to 14 do begin;
  49.       GotoXY(27, Temprow);
  50.       write(Copy(Words[Row],27,26));
  51.       Temprow := Temprow + 1;
  52.       Row := Row + 1;
  53.    end;
  54.    Row := Temp;
  55. end;
  56.  
  57. procedure DirSetup(InitReset: TempString ;
  58.                    var error: Integer  );
  59. begin
  60.    Error := 0;
  61.    if InitReset = 'INIT' then
  62.       begin           {---------- Initialization processes ------------}
  63.          For I := 1 to 43 do                    {Initialize our DTA Buffer}
  64.              OurDTA[I]:=0;
  65.  
  66.          dosrec.ax := $2F00;                      { Save Current DTA pointer}
  67.          Intr($21,dosrec);                        { to be restored later    }
  68.          CurDTASeg := dosrec.es;
  69.          CurDTAOfs := dosrec.bx;
  70.          error := dosrec.ax and $FF;
  71.  
  72.          if error = 0 then
  73.             begin
  74.             OurDTAseg := seg(OurDTA);           {Point DOS to our        }
  75.             OurDTAofs := ofs(OurDTA);           {DTA Buffer              }
  76.             dosrec.ax := $1A00;
  77.             dosrec.ds := OurDTASeg;
  78.             dosrec.dx := OurDTAOfs;
  79.             Intr($21,dosrec);
  80.             error := dosrec.ax and $FF;
  81.          end;
  82.       end;
  83. end;
  84.  
  85. procedure DirGet  (Func     : TempString ;
  86.                    Asciiz   : TempString ;
  87.                var FileName : TempString ;
  88.                    Option   : Integer  ;
  89.                var Error    : Integer  );
  90.  
  91. begin
  92.     error := 0;
  93.  
  94.     If Func = 'FIRST' then
  95.        begin
  96.        asciiz[length(asciiz)+1]:=chr(0); { Terminate name with hex00 }
  97.        dosrec.ax := $4E00;          { Get first directory entry }
  98.        dosrec.ds := seg(Asciiz);    { Point to the file mask }
  99.        dosrec.dx := ofs(Asciiz);
  100.        dosrec.dx := dosrec.dx + 1;    { Point past string's length byte }
  101.        dosrec.cx := Option;
  102.        end
  103.     else
  104.        dosrec.ax := $4F00;          {Get next directory entry}
  105.  
  106.     Intr($21,dosrec);               { Execute MSDos call }
  107.     error := dosrec.ax and $FF;     { Get error return }
  108.     I := 1;
  109.     If error = 0 then
  110.     Repeat                        { Get name from the DTA area }
  111.         FileName[I]:=chr(mem[OurDTASeg:OurDTAOfs + 29 + I]);
  112.         I := I + 1;
  113.     Until (not (FileName[I - 1] in [' '..'~']));
  114.     FileName[0]:=chr(I-1)         { set string length because assigning }
  115.                                   { by element does not set length }
  116. end;
  117.  
  118. procedure PrintDir;
  119. var err : integer;
  120.     firstname, nextnames : TempString;
  121.  
  122. Begin
  123.    Fill_In;
  124.    ClrScr;
  125.    DirSetup('INIT',err);
  126.    DirGet('FIRST','????????.???'+chr(0),FIRSTNAME,8,err);
  127.    writeln('Directory of A: Volume name is ',FIRSTNAME);
  128.    writeln('Only Turbo Script files listed.');
  129.    writeln;
  130.    DirSetup('INIT',err);
  131.    DirGet('FIRST','A:????????.FIL'+chr(0),Firstname,3,err);
  132.    write(copy(Firstname,1,Pos('.',Firstname)-1):8,'        ');
  133.    repeat
  134.        DirGet('NEXT','A:????????.FIL'+chr(0),Nextnames,3,err);
  135.        write(copy(Nextnames,1,pos('.',Nextnames)-1):8,'        ');
  136.    until err<>0;
  137.    dosrec.ax := $3600;
  138.    dosrec.dx := 0;
  139.    Intr($21, dosrec);
  140.    writeln;
  141.    writeln('      ',dosrec.bx,'k bytes free');
  142.    writeln;
  143.    writeln;
  144.    writeln('Press any key to continue...');
  145.    read(Kbd, Choice);
  146. end;
  147.  
  148. procedure PrintWords;
  149. begin
  150.     ClrScr;
  151.     for i := 1 to 21 do begin
  152.        if Words[i] = Test then writeln else writeln(Words[i]);
  153.     end;
  154.     write(Words[22]);
  155. end;
  156.  
  157. function Replicate ( Count, Ascii : Integer ) : TempString;
  158. var
  159.   Temp : TempString;
  160.    I   : Byte;
  161.  
  162. Begin
  163.   Temp := '';
  164.   For I := 1 to Count do
  165.     Temp := Temp + chr(Ascii);
  166.   Replicate := Temp;
  167. end;
  168.  
  169. procedure ClearBuf;
  170. var dummy : char;
  171. begin
  172.    while KeyPressed do read(Kbd, dummy);
  173. end;
  174.  
  175. procedure Data_In(Line : integer;Var FileName : TempString);
  176. var
  177.    count, Maxcount : integer;
  178.    Letter : char;
  179.    NoGood, NameSet, ValidLetters, LowerCase : set of char;
  180.  
  181. begin
  182.    FileName := '--------.---';
  183.    count := 1;
  184.    ValidLetters := ['!'..'~'];
  185.    LowerCase := ['a'..'z'];
  186.    NoGood := ['*','<'..'?','[',']',' ','.'];
  187.    NameSet := ValidLetters - NoGood;
  188.    GotoXY(1,Line);
  189.    write(FileName);
  190.    GotoXY(1,Line);
  191.    Maxcount := Length(FileName);
  192.    repeat
  193.      GotoXY(count,Line);
  194.      read(Kbd, Letter);
  195.      if Letter in Lowercase then Letter := UpCase(Letter);
  196.      if (Letter = ' ') or (Letter = '.') then count := maxcount - 3;
  197.      if Letter in NameSet
  198.         then begin
  199.            FileName[count] := Letter;
  200.            GotoXY(1,Line);
  201.            Write(FileName);
  202.            count := count + 1;
  203.         end
  204.      else
  205.        if Letter = chr(8) then begin
  206.           if count = Pos('.',FileName) + 1 then count := count - 2
  207.              else count := count - 1;
  208.           if count < 1 then count := 1;
  209.           FileName[count] := '-';
  210.           GotoXY(1,Line);
  211.           write(FileName);
  212.         end
  213.      else if (Letter <> ' ') and (Letter <> chr(13)) and (ord(Letter) <> 27)
  214.         and (Letter <> '.') then write(chr(7));
  215.      if count = Pos('.',FileName) then count := count + 1;
  216.   until (count = Maxcount + 1) or (Letter = chr(13)) or (ord(Letter) = 27);
  217.   if (ord(Letter) = 27) or (count=1) then Exit := true else begin
  218.      if Copy(Filename, Maxcount-2,1) = '-' then begin
  219.         Filename := Copy(Filename, 1, Length(Filename)-4);
  220.         Filename := Filename + '.FIL';
  221.      end;
  222.      repeat
  223.         Delete(Filename,Pos('-',Filename),1);
  224.      until Pos('-',Filename)=0;
  225.      GotoXY(1,Line);
  226.      Write('                ');
  227.      GotoXY(1,Line);
  228.      Write(Filename);
  229.   end;
  230. end;
  231.  
  232. procedure Initialize;
  233.  begin
  234.     CrtInit;
  235.     Window(1,1,80,25);
  236.     GotoXY(1,1);
  237.     Write(Replicate(80,205));
  238.     GotoXY(1,24);
  239.     Write(Replicate(80,196));
  240.     GotoXY(16,1);
  241.     Write('Turbo Script');
  242.     GotoXY(1,25);
  243.     LowVideo;
  244.     write('Help ':6,'Ser/Rep ':10,'Tabs ':7,'Title ':8,'DOS ':6);
  245.     write('InsLine ':10,'DelLine ':10,'Print ':8,'Load ':7,'Save ':7);
  246.     NormVideo;
  247.     for i := 1 to 10 do begin
  248.        GotoXY(Positions[i], 25);
  249.        write(Digits[i]);
  250.      end;
  251.     Window(1,2,80,23);
  252.     Row := 1;
  253.     Column := 1;
  254.     ScreenRow := 1;
  255.     MaxRow := 1;
  256.     TempWord := Replicate(79,32);
  257.     Test := TempWord;
  258.     for i := 1 to 500 do Words[i] := TempWord;
  259.     TempWord := '';
  260.     Insertmode := false;
  261.     Undermode := false;
  262.     Boldmode := false;
  263.     Italicmode := false;
  264.     Exit := false;
  265.     NumEnd := 1;
  266.     for i := 1 to 80 do Tabset[i] := false;
  267.     Tabset[6] := true;
  268.     Tabset[40] := true;
  269. end;
  270.  
  271. procedure Printrow;
  272. begin
  273.    Window(1,1,80,25);
  274.    GotoXY(43,1);
  275.    writeln('Row = ',Row : 3,'  Column = ',Column : 2);
  276.    Window(1,2,80,23);
  277. end;
  278.  
  279. procedure Menu(Title, Choice1, Choice2, Choice3, Choice4, Choice5 : TempString);
  280. begin
  281.    ClearBuf;
  282.    ClrScr;
  283.    writeln(Title);
  284.    writeln;
  285.    writeln(Choice1);
  286.    writeln(Choice2);
  287.    writeln(Choice3);
  288.    writeln(Choice4);
  289.    writeln(Choice5);
  290.    writeln;
  291.    write('? ');
  292.    GotoXY(1,10);
  293.    write('Press Esc to exit');
  294.    GotoXY(3,9);
  295.    read(Kbd, Choice);
  296.    If ord(Choice) = 27 then Exit := true else Val(Choice, Num, code);
  297.    if (code>0) or (Num>5) or (Num<1) then Num := 0;
  298. end;
  299.  
  300. procedure Frame(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY: Integer);
  301. var
  302.    i: Integer;
  303. begin
  304.    GotoXY(UpperLeftX, UpperLeftY);  Write(chr(201));
  305.    for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  306.    Write(chr(187));
  307.    for i:=UpperLeftY+1 to LowerRightY-1 do
  308.    begin
  309.       GotoXY(UpperLeftX , i);  Write(chr(186));
  310.       GotoXY(LowerRightX, i);  Write(chr(186));
  311.    end;
  312.    GotoXY(UpperLeftX, LowerRightY);
  313.    Write(chr(200));
  314.    for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  315.    Write(chr(188));
  316. end  { Frame };
  317.  
  318. procedure CommandWindow(Strg : TempString);
  319. begin
  320.    Window(28,6,52,18);
  321.    ClrScr;
  322.    Window(1,2,80,23);
  323.    Frame(28,5,52,17);
  324.    Window(30,7,50,17);
  325.    GotoXY(1,1);
  326.    write(Replicate(20,223));
  327.    GotoXY(1,2);
  328.    write(Strg);
  329.    GotoXY(1,3);
  330.    write(Replicate(20,220));
  331. end;
  332.  
  333. procedure ClearScreen;
  334. begin
  335.    Temp1 := Row;
  336.    Temp2 := ScreenRow;
  337.    Temp3 := Column;
  338.    CommandWindow('');
  339.    ClrScr;
  340.    GotoXY(1,3);
  341.    write('Clear Memory, Erase  Text?');
  342.    writeln;
  343.    writeln;
  344.    write('ARE YOU SURE? (Y/N) ');
  345.    read(Kbd,Inkey);
  346.    write(Inkey);
  347.    if (Inkey = 'y') or (Inkey = 'Y') then begin
  348.         TempWord := Replicate(79,32);
  349.         for i := 1 to 500 do Words[i] := TempWord;
  350.         Row := 1;
  351.         ScreenRow := 1;
  352.         Column := 1;
  353.         MaxRow := 1;
  354.      end
  355.    else begin
  356.        Exit := true;
  357.        Row := Temp1;
  358.        ScreenRow := Temp2;
  359.        Column := Temp3;
  360.    end;
  361. end;
  362.  
  363. function GetKey(var secnum : boolean; var Inkey : char) : boolean;
  364. begin
  365.    if KeyPressed then begin
  366.       result := true;
  367.       dosrec.ax := $0800;
  368.       msdos(dosrec);
  369.       Inkey := chr(lo(dosrec.ax));
  370.       Secnum := ord(Inkey) = 0;
  371.       if Secnum then begin
  372.          dosrec.ax := $0800;
  373.          msdos(dosrec);
  374.          Keynum := ord(chr(lo(dosrec.ax)));
  375.       end
  376.       else if ord(Inkey) <= 27 then begin
  377.          Secnum := true;
  378.          Keynum := ord(Inkey);
  379.       end
  380.       else begin
  381.          Keynum := ord(Inkey);
  382.          Secnum := false;
  383.       end
  384.    end
  385.    else begin
  386.       Getkey := false;
  387.       secnum := false;
  388.    end;
  389. end;
  390.  
  391. procedure WordWrap;
  392. var SpacePosition : integer;
  393.  
  394. begin
  395.    SpacePosition := 79;
  396.    TempWord := Words[Row];
  397.    Sound(400);
  398.    Delay(20);
  399.    NoSound;
  400.    repeat
  401.       SpacePosition := SpacePosition - 1;
  402.    until TempWord[SpacePosition] = ' ';
  403.    if SpacePosition < 2 then SpacePosition := 2;
  404.    Words[Row+1] := Copy(Words[Row], SpacePosition + 1, 79-(SpacePosition+1)) +
  405.                    Inkey + Copy(Words[Row+1], 1, SpacePosition - 2);
  406.    Words[Row] := Copy(Words[Row], 1, SpacePosition - 1) + Replicate(80 - SpacePosition, 32);
  407.    ScreenRow := ScreenRow + 1;
  408.    if ScreenRow > 22 then begin
  409.      ScreenRow := 22;
  410.      GotoXY(1,1);
  411.      DelLine;
  412.      GotoXY(1, ScreenRow-1);
  413.      writeln(Words[Row]);
  414.      write(Words[Row+1]);
  415.     end
  416.    else begin
  417.       GotoXY(1, ScreenRow-1);
  418.       writeln(words[Row]);
  419.       write(Words[Row+1]);
  420.      end;
  421.    Row := Row + 1;
  422.    if Row > MaxRow then MaxRow := Row;
  423.    Column := Length(Words[Row])- SpacePosition + 3;
  424. end;
  425.  
  426. procedure Character;
  427. begin
  428.    if Column = 79 then WordWrap else
  429.    begin
  430.       GotoXY(Column,ScreenRow);
  431.       write(Inkey);
  432.       Insert(Inkey, Words[Row], Column);
  433.       if not Insertmode then Delete(Words[Row],Column + 1,1);
  434.       Column := Column + 1;
  435.       if Column = 70 then begin
  436.          Sound(1010);
  437.          Delay(10);
  438.          NoSound;
  439.       end;
  440.    end;
  441. end;
  442.  
  443. procedure Del;
  444.   begin
  445.     ch := Copy(Words[Row], Column, 1);
  446.     Delete(Words[Row], Column, 1);
  447.     Words[Row] := Words[Row] + ' ';
  448.     if ch in ['▌','▐'] then boldmode := not boldmode;
  449.     if ch in ['«','»'] then italicmode := not italicmode;
  450.     GotoXY(1, ScreenRow);
  451.     if ScreenRow = 22 then write(Words[Row]) else writeln(Words[Row]);
  452.   end;
  453.  
  454. procedure Backspace;
  455.   begin
  456.     if Column > 1 then begin
  457.        Column := Column - 1;
  458.        Del;
  459.     end;
  460.  end;
  461.  
  462. procedure InsertLine;
  463. begin
  464.    InsLine;
  465.    for i := MaxRow + 1 downto Row do Words[i+1] := Words[i];
  466.    Words[Row] := Replicate(79,32);
  467.    MaxRow := MaxRow + 1;
  468. end;
  469.  
  470. procedure Enter;
  471. begin
  472.   column := 1;
  473.   row := row + 1;
  474.   if row > MaxRow then MaxRow := Row;
  475.   ScreenRow := Screenrow + 1;
  476.   if ScreenRow > 22 then begin
  477.      GotoXY(1,1);
  478.      DelLine;
  479.      ScreenRow := 22;
  480.      GotoXY(1, ScreenRow);
  481.      write(Words[Row]);
  482.   end;
  483.   GotoXY(Column, Screenrow);
  484.   if InsertMode then InsertLine;
  485. end;
  486.  
  487. procedure CursorLeft;
  488. begin
  489.   column := column - 1;
  490.   if column < 1 then begin
  491.      column := 79;
  492.      if Row = 1 then Row := 1 else Row := Row - 1;
  493.      if ScreenRow = 1 then ScreenRow := 1 else ScreenRow := ScreenRow - 1;
  494.      end
  495. end;
  496.  
  497. procedure CursorRight;
  498. begin
  499.   column := column + 1;
  500.   If Column > 79 then begin
  501.   Column := 1;
  502.   Row := Row + 1;
  503.   if Row > MaxRow then MaxRow := Row;
  504.   If ScreenRow < 22 then ScreenRow := ScreenRow + 1 else begin
  505.      ScreenRow := 22;
  506.      GotoXY(1,1);
  507.      DelLine;
  508.      GotoXY(1, ScreenRow);
  509.      write(Words[Row]);
  510.     end;
  511.   end;
  512. end;
  513.  
  514. procedure CursorUp;
  515. var Count : integer;
  516. begin
  517.    if row = 1 then Row_One := true else Row_One := false;
  518.    row := row - 1;
  519.    if row < 1 then row := 1;
  520.    if (ScreenRow = 1) and not Row_One then begin
  521.        GotoXY(1,1);
  522.        InsLine;
  523.        GotoXY(1,1);
  524.        write(Words[Row]);
  525.    end;
  526.    ScreenRow := ScreenRow - 1;
  527.    if ScreenRow < 1 then ScreenRow := 1;
  528. end;
  529.  
  530. procedure CursorDown;
  531. begin
  532.   row := row + 1;
  533.   if row > MaxRow then MaxRow := Row;
  534.   ScreenRow := ScreenRow + 1;
  535.   if ScreenRow > 22 then begin
  536.      ScreenRow := 22;
  537.      GotoXY(1,1);
  538.      DelLine;
  539.      GotoXY(1, ScreenRow);
  540.      write(Words[Row]);
  541.   end;
  542. end;
  543.  
  544. procedure Ins;
  545. begin
  546.   if Insertmode then Insertmode := false
  547.     else Insertmode := true;
  548.   Window(1,1,80,25);
  549.   GotoXY(1,1);
  550.   if Insertmode = true then write('Insert') else write(Replicate(7,205));
  551. end;
  552.  
  553. procedure Warning;
  554.  
  555. begin
  556.    ClrScr;
  557.    Writeln(chr(7),'<<<<<<<<<<>>>>>>>>>>  ');
  558.    writeln('That file already');
  559.    writeln('    exists.');
  560.    writeln;
  561.    writeln('Replace it (Y/N)?');
  562.    writeln;
  563.    writeln('<<<<<<<<<<>>>>>>>>>>');
  564.    GotoXY(19,6);
  565.    Read(Kbd, Choice);
  566.    GotoXY(19,6);
  567.    write(Choice);
  568.    if (Choice = 'n') or (Choice = 'N') then Exit := true;
  569. end;
  570.  
  571. procedure Savefile;
  572. var Exist : boolean;
  573.  
  574. begin
  575.    Temp1 := Row;
  576.    Temp2 := ScreenRow;
  577.    Temp3 := Column;
  578.    CommandWindow('     Save File');
  579.    GotoXY(1,5);
  580.    writeln('Enter File Name:');
  581.    write('Default = .FIL');
  582.    GotoXY(1,10);
  583.    write('Press Esc to exit');
  584.    Data_In(8, Filename);
  585.    if Exit = false then begin
  586.       GotoXY(1,10);
  587.       Assign(TextFile, Filename);
  588.       {$I-}
  589.       Reset(TextFile);
  590.       {$I+}
  591.       Exist := (IOresult = 0);
  592.       if Exist = true then Warning;
  593.       if Exit = false then begin
  594.          Rewrite(TextFile);
  595.          Row := 1;
  596.          for i := 1 to MaxRow + 1 do begin
  597.             Writeln(TextFile, Words[Row]);
  598.             Row := Row + 1;
  599.          end;
  600.          Close(TextFile);
  601.       end;
  602.    end;
  603.    Row := Temp1;
  604.    Fill_In;
  605.    Row := Temp1;
  606.    ScreenRow := Temp2;
  607.    Column := Temp3;
  608. end;
  609.  
  610. procedure Loadfile;
  611. var  Exist : boolean;
  612.  
  613. begin
  614.    Temp1 := Row;
  615.    Temp2 := ScreenRow;
  616.    Temp3 := Column;
  617.    CommandWindow('     Load File');
  618.    GotoXY(1,5);
  619.    writeln('Enter File Name:');
  620.    write('Default = .FIL');
  621.    GotoXY(1,10);
  622.    write('Press Esc to exit');
  623.    Data_In(8, Filename);
  624.    if Exit = false then begin
  625.       GotoXY(1,10);
  626.       Assign(TextFile, Filename);
  627.       {$I-}
  628.       Reset(TextFile);
  629.       {$I+}
  630.       Exist := (IOresult = 0);
  631.       if Exist = true then begin
  632.          TempWord := Test;
  633.          ClearScreen;
  634.          if Exit = false then begin
  635.             While EOF(Textfile) = false do begin
  636.                Readln(TextFile, Words[Row]);
  637.                if Length(Words[Row]) >= 80 then Words[Row] := Copy(Words[Row], 1, 79);
  638.                Row := Row + 1;
  639.                end;
  640.             Close(TextFile);
  641.             MaxRow := Row + 1;
  642.             Window(27,6,52,18);
  643.             ClrScr;
  644.             Window(1,2,80,23);
  645.             ClrScr;
  646.             GotoXY(1,1);
  647.             PrintWords;
  648.             Row := 1;
  649.             Column := 1;
  650.             ScreenRow := 1;
  651.          end;
  652.       end;
  653.       if Exist=false then begin
  654.          ClrScr;
  655.          writeln(chr(7));
  656.          writeln('File does not exist');
  657.          Delay(1000);
  658.          Exit := true;
  659.       end;
  660.    end;
  661.    if Exit = true then begin
  662.       Row := Temp1;
  663.       Fill_In;
  664.       Row := Temp1;
  665.       ScreenRow := Temp2;
  666.       Column := Temp3;
  667.    end;
  668. end;
  669.  
  670. procedure SetMargins;
  671. begin
  672.    TopMargin := 0;
  673.    Menu('Select Top Margin:','1.  1"','2.  1 1/2"','3.  2"','4.  None','');
  674.    if Num in [1..3] then TopMargin := (Num + 1) * 3;
  675.    if Exit = false then begin
  676.       ClrScr;
  677.       writeln('Set Horizontal       Margins (Y/N)');
  678.       read(Kbd, Choice);
  679.       if (Choice = 'Y') or (Choice = 'y') then begin
  680.           writeln;
  681.           writeln('Enter Left margin:');
  682.           Read(LeftMarg);
  683.           writeln;
  684.           writeln('Enter Right margin:');
  685.           Read(RightMarg);
  686.           Typeset := Typeset + chr(27) + chr(77) + chr(LeftMarg) +
  687.                                chr(27) + chr(81) + chr(RightMarg);
  688.       end;
  689.    end;
  690. end;
  691.  
  692. procedure PrintTitle;
  693. var Titlename : TempString;
  694.     spacing : integer;
  695.  
  696. begin
  697.   CommandWindow('        Title');
  698.   GotoXY(1,5);
  699.   writeln('Enter title:');
  700.   read(Titlename);
  701.   Write(Lst, chr(27), chr(71), chr(27), chr(69), chr(27), chr(14));
  702.   Spacing := 20 - Length(Titlename) div 2;
  703.   Spacing := Spacing + Length(Titlename);
  704.   writeln(Lst, Titlename : Spacing);
  705.   writeln(Lst, chr(27), chr(64), Typeset);
  706.   ClrScr;
  707.   GotoXY(1,3);
  708.   TextColor(White + Blink);
  709.   writeln('Printing...');
  710.   TextColor(White);
  711.   writeln;
  712.   writeln('<< Press any key >>');
  713.   writeln('<< to abort.     >>');
  714. end;
  715.  
  716. procedure SuperScript;
  717. begin
  718.    Write(Lst, chr(27), chr(83), chr(0));
  719.    Index := Index + 1;
  720.    repeat
  721.       Write(Lst, TempWord[Index]);
  722.       Index := Index + 1;
  723.    until not(TempWord[Index] in ['0'..'9','-']) = true;
  724.    write(Lst, chr(27), chr(84));
  725. end;
  726.  
  727. procedure SubScript;
  728. begin
  729.    Write(Lst, chr(27), chr(83), chr(1));
  730.    Index := Index + 1;
  731.    repeat
  732.       Write(Lst, TempWord[Index]);
  733.       Index := Index + 1;
  734.    until not(TempWord[Index] in ['0'..'9']) = true;
  735.    write(Lst, chr(27), chr(84));
  736. end;
  737.  
  738. procedure UnderLine;
  739. begin
  740.    if Undermode = true then begin
  741.       Undermode := false;
  742.       Write(Lst, chr(27), chr(45), chr(0));
  743.    end
  744.    else begin
  745.       Undermode := true;
  746.       Write(Lst, chr(27), chr(45), chr(1));
  747.    end;
  748. end;
  749.  
  750. procedure Boldface;
  751. begin
  752.    if Boldmode = true then begin
  753.       Boldmode := false;
  754.       Write(Lst, chr(27), chr(72));
  755.    end
  756.    else begin
  757.       Boldmode := true;
  758.       Write(Lst, chr(27), chr(71));
  759.    end;
  760. end;
  761.  
  762. procedure Italics;
  763. begin
  764.    if Italicmode = true then begin
  765.       Italicmode := false;
  766.       Write(Lst, chr(27), chr(53));
  767.    end
  768.    else begin
  769.       Italicmode := true;
  770.       Write(Lst, chr(27), chr(52));
  771.    end;
  772. end;
  773.  
  774. procedure PrintFile;
  775. var lines, Linespaces, j : integer;
  776.     Perfover, Special : boolean;
  777.  
  778. begin
  779.    Temp1 := Row;
  780.    Temp2 := ScreenRow;
  781.    Temp3 := Column;
  782.    if Boldmode = true then I := 2656;
  783.    CommandWindow('     Print file');
  784.    Typeset := chr(27)+chr(64);
  785.    GotoXY(1,7);
  786.    writeln('Press any key...');
  787.    repeat until KeyPressed;
  788.    repeat
  789.       Menu('Choose print style:', '1.  Elite', '2.  Boldface', '3.  Italic',
  790.            '4.  Compressed', '5.  Continue');
  791.       Case Num of
  792.           1 : Typeset := Concat(Typeset,chr(27),chr(66),chr(2),
  793.                                 chr(27),chr(77),chr(8));
  794.           2 : Typeset := Concat(Typeset,chr(27),chr(71));
  795.           3 : Typeset := Concat(Typeset,chr(27),chr(52));
  796.           4 : Typeset := Concat(Typeset,chr(15),chr(27),chr(77),chr(32));
  797.           5 :;
  798.         else
  799.           if Exit = false then write(chr(7));
  800.         end;
  801.       if Num in [1..4] then begin
  802.          Sound(300);
  803.          Delay(50);
  804.          NoSound;
  805.          write(' Done.');
  806.          Delay(300);
  807.       end;
  808.    until (Num = 5) or (Exit = true);
  809.    if Exit = false then begin
  810.       SetMargins;
  811.       ClrScr;
  812.       if Exit = false then begin
  813.          Typeset := Typeset + chr(27) + chr(82) + chr(Topmargin);
  814.          ClrScr;
  815.          writeln('Set line spacing:');
  816.          writeln;
  817.          writeln('1.  Single');
  818.          writeln('2.  Double');
  819.          writeln('3.  Triple');
  820.          writeln;
  821.          read(Kbd, Choice);
  822.          Val(Choice, Num, code);
  823.          if (Num in [1..3]) and (code = 0) then Linespaces := Num;
  824.          writeln;
  825.          Write('Do you want automaticperf skip over? ');
  826.          read(Kbd, Choice);
  827.          if (Choice = 'Y') or (Choice = 'y') then Perfover := true else
  828.                  Perfover := false;
  829.          if Perfover = true then Typeset := Typeset+chr(27)+chr(78)+chr(Topmargin);
  830.          ClearBuf;
  831.          ClrScr;
  832.          Writeln('Scroll paper to perf');
  833.          Writeln('and press any key to');
  834.          writeln('print, or Esc to');
  835.          writeln('exit');
  836.          read(Kbd, Choice);
  837.          if ord(Choice) <> 27 then begin
  838.             ClrScr;
  839.             GotoXY(1,3);
  840.             TextColor(White + Blink);
  841.             writeln('Printing...');
  842.             TextColor(White);
  843.             writeln;
  844.             writeln('<< Press any key >>');
  845.             writeln('<< to abort.     >>');
  846.             writeln(Lst, Typeset);
  847.             i := 0;
  848.             for j := 1 to TopMargin do write(Lst,chr(10));
  849.             Test := Replicate(79,32);
  850.             While (not KeyPressed) and (i < MaxRow + 1) do begin
  851.                TempWord := Test;
  852.                i := i + 1;
  853.                if Copy(Words[i],1,5) = 'Title' then PrintTitle
  854.                else begin
  855.                   TempWord := Words[i];
  856.                   Index := 0;
  857.                   if TempWord = Test then write(Lst, chr(13)) else
  858.                   begin
  859.                      repeat
  860.                         Index := Index + 1;
  861.                         If TempWord[Index] = '\' then Underline;
  862.                         If TempWord[Index] = '~' then SuperScript;
  863.                         if TempWord[Index] = '|' then Subscript;
  864.                         if TempWord[Index] in ['«','»'] then Italics;
  865.                         if TempWord[Index] in ['▐','▌'] then Boldface;
  866.                         if not(TempWord[Index] in ['\','~','|','▐','▌','«','»'])
  867.                          = true then Write(Lst, TempWord[Index]);
  868.                      until Index >= 79;
  869.                      Write(Lst, chr(13));
  870.                   end;
  871.                   for j := 1 to Linespaces do write(Lst, chr(10));
  872.                end;
  873.             end;
  874.          end;
  875.       end;
  876.    end;
  877.    Fill_In;
  878.    Row := Temp1;
  879.    ScreenRow := Temp2;
  880.    Column := Temp3;
  881.    if I = 2656 then Boldmode := true;
  882. end;
  883.  
  884. procedure Search;
  885. var SearchString, Temp : TempString;
  886.     Pointer, Position, Line, Len : integer;
  887.  
  888. begin
  889.    Line := 2;
  890.    CommandWindow('       Search');
  891.    GotoXY(1, 5);
  892.    writeln('Enter String: ');
  893.    writeln;
  894.    write('? ');
  895.    read(SearchString);
  896.    Len := Length(SearchString);
  897.    Fill_In;
  898.    ClrScr;
  899.    for i := 1 to MaxRow do begin
  900.       Pointer := Pos(SearchString, Words[i]);
  901.       if (Exit = false) and (Pointer > 0) then begin
  902.          Temp := Words[i];
  903.          Position := Pointer;
  904.          GotoXY(1, Line);
  905.          LowVideo;
  906.          write(Temp);
  907.          NormVideo;
  908.          While Pointer > 0 do begin
  909.             GotoXY(Position, Line);
  910.             write(Copy(Temp, Pointer, Len));
  911.             Temp := Copy(Temp, Pointer + Len + 1,
  912.                          80 - Pointer + Len + 1);
  913.             Pointer := Pos(SearchString, Temp);
  914.             Position := Position + Pointer + Len;
  915.          end;
  916.          writeln;
  917.          Line := Line + 1;
  918.          if Line = 20 then begin
  919.             GotoXY(1, 22);
  920.             write('Press any key to continue or Esc to exit ...');
  921.             read(Kbd, Choice);
  922.             if ord(Choice) = 27 then Exit := true else begin
  923.                ClrScr;
  924.                line := 2;
  925.             end;
  926.          end;
  927.          if line > 2 then begin
  928.             read(Kbd, Choice);
  929.             if ord(Choice) = 27 then Exit := true;
  930.          end;
  931.       end;
  932.    end;
  933.    writeln;
  934.    writeln;
  935.    writeln('End of search');
  936.    repeat until Keypressed;
  937. end;
  938.  
  939. procedure Replace;
  940. var SearchString, Replacement : TempString;
  941.     Pointer, Line, Len : integer;
  942.  
  943. begin
  944.    Line := 2;
  945.    CommandWindow('      Replace');
  946.    GotoXY(1, 5);
  947.    writeln('Enter String: ');
  948.    writeln;
  949.    write('? ');
  950.    read(SearchString);
  951.    writeln;
  952.    writeln('Enter Replacement:');
  953.    writeln;
  954.    write('? ');
  955.    read(Replacement);
  956.    Len := Length(Replacement);
  957.    Fill_In;
  958.    ClrScr;
  959.    for i := 1 to MaxRow do begin
  960.       Pointer := Pos(SearchString, Words[i]);
  961.       if (Pointer > 0) and (Exit = false) then begin
  962.          GotoXY(1, Line);
  963.          LowVideo;
  964.          write(Words[i]);
  965.          NormVideo;
  966.          GotoXY(Pointer, Line);
  967.          write(Copy(Words[i], Pointer, Length(SearchString)));
  968.          GotoXY(1,22);
  969.          write('Replace Y/N');
  970.          read(Kbd, Choice);
  971.          if ord(Choice) = 27 then Exit := true else if (Choice = 'Y') or
  972.          (Choice = 'y') then begin
  973.             Words[i] := Copy(Words[i],1,Pointer-1) + Replacement +
  974.                         Copy(Words[i], Pointer + Length(SearchString), 80-Len+1);
  975.             GotoXY(1, Line);
  976.             LowVideo;
  977.             write(Words[i]);
  978.             NormVideo;
  979.             GotoXY(Pointer, Line);
  980.             write(Copy(Words[i], Pointer, Len));
  981.          end
  982.          else begin
  983.             GotoXY(80, Line);
  984.             write('N');
  985.          end;
  986.          Line := Line + 1;
  987.          if Line = 20 then begin
  988.             writeln('Press any key to continue or Esc to exit ...');
  989.             read(Kbd, Choice);
  990.             if ord(Choice) = 27 then Exit := true else begin
  991.                ClrScr;
  992.                line := 2;
  993.             end;
  994.          end;
  995.       end;
  996.    end;
  997.    writeln;
  998.    write('End of replace');
  999.    repeat until Keypressed;
  1000. end;
  1001.  
  1002. procedure Menu_S_R;
  1003. var Good : boolean;
  1004.  
  1005. begin
  1006.    Temp1 := Row;
  1007.    Temp2 := ScreenRow;
  1008.    Temp3 := Column;
  1009.    CommandWindow('  Search / Replace');
  1010.    Good := True;
  1011.    GotoXY(1,5);
  1012.    Writeln('Enter Choice: ');
  1013.    writeln;
  1014.    writeln('1.  Search');
  1015.    writeln('2.  Replace');
  1016.    writeln;
  1017.    write('? ');
  1018.    GotoXY(1,10);
  1019.    write('Press Esc to exit');
  1020.    read(Kbd, Choice);
  1021.    if ord(Choice) = 27 then code := 1 else Val(Choice, Num, code);
  1022.    if (code = 0) and (Num in [1,2]) then
  1023.       case Num of
  1024.          1 : Search;
  1025.          2 : Replace;
  1026.         end
  1027.       else begin
  1028.          if code = 0 then write(chr(7));
  1029.          Fill_In;
  1030.          Row := Temp1;
  1031.          ScreenRow := Temp2;
  1032.          Column := Temp3;
  1033.          Good := false;
  1034.       end;
  1035.    if Good then begin
  1036.       Row := 1;
  1037.       Column := 1;
  1038.       ScreenRow := 1;
  1039.       ClrScr;
  1040.       GotoXY(1,1);
  1041.       PrintWords;
  1042.    end;
  1043. end;
  1044.  
  1045. procedure DelFile;
  1046. var Filename : TempString;
  1047.     Exist : boolean;
  1048.  
  1049. begin
  1050.   ClrScr;
  1051.   writeln('Enter file to Delete:');
  1052.   Data_In(3, FileName);
  1053.   Assign(Textfile, FileName);
  1054.   {$I-}
  1055.   Reset(Textfile);
  1056.   {$I+}
  1057.   Exist := (IOresult = 0);
  1058.   if Exist = true then begin
  1059.      Erase(Textfile);
  1060.      GotoXY(1,6);
  1061.      writeln('File deleted');
  1062.      Delay(1000);
  1063.   end
  1064.    else begin
  1065.       GotoXY(1,6);
  1066.       writeln(chr(7),'File does not exist');
  1067.       Delay(1000);
  1068.    end;
  1069. end;
  1070.  
  1071. procedure RenFile;
  1072. var OldName, NewName : TempString;
  1073.     Exist : boolean;
  1074.  
  1075. begin
  1076.    ClrScr;
  1077.    Writeln('Enter old file name:');
  1078.    Data_In(3, OldName);
  1079.    Assign(Textfile, OldName);
  1080.    {$I-}
  1081.    Reset(Textfile);
  1082.    {$I+}
  1083.    Exist := (IOresult = 0);
  1084.    if Exist = true then begin
  1085.       Close(Textfile);
  1086.       writeln;
  1087.       writeln;
  1088.       writeln('Enter new name:');
  1089.       Data_In(6, NewName);
  1090.       Assign(Textfile, NewName);
  1091.       {$I-}
  1092.       Reset(Textfile);
  1093.       {$I+}
  1094.       Exist := (IOresult = 0);
  1095.       if Exist = false then begin
  1096.          Close(Textfile);
  1097.          Assign(Textfile, OldName);
  1098.          Rename(Textfile, NewName);
  1099.          Close(Textfile);
  1100.       end
  1101.       else begin
  1102.          GotoXY(1,8);
  1103.          write(chr(7),'New file already exists');
  1104.          Delay(1000);
  1105.       end;
  1106.    end
  1107.    else begin
  1108.       GotoXY(1,8);
  1109.       write(chr(7),'File does not exist');
  1110.       Delay(1000);
  1111.    end;
  1112. end;
  1113.  
  1114. procedure Copyfile;
  1115. var Firstname, SecondName : TempString;
  1116.     SecondFile : Text;
  1117.     Exist : boolean;
  1118.  
  1119. begin
  1120.    ClrScr;
  1121.    Writeln('Enter source file:');
  1122.    Data_In(3, Firstname);
  1123.    Assign(Textfile, Firstname);
  1124.    {$I-}
  1125.    Reset(Textfile);
  1126.    {$I+}
  1127.    Exist := (IOresult = 0);
  1128.    if Exist = true then begin
  1129.       writeln;
  1130.       writeln;
  1131.       writeln('Enter new name:');
  1132.       Data_In(6, SecondName);
  1133.       Assign(SecondFile, SecondName);
  1134.       {$I-}
  1135.       Reset(SecondFile);
  1136.       {$I+}
  1137.       Exist := (IOresult = 0);
  1138.       if Exist = false then begin
  1139.          Close(SecondFile);
  1140.          Rewrite(SecondFile);
  1141.          writeln;
  1142.          writeln;
  1143.          writeln('Copying......');
  1144.          while EOF(Textfile) = false do begin
  1145.             readln(Textfile, TempWord);
  1146.             Writeln(SecondFile, TempWord);
  1147.             TempWord := '';
  1148.          end;
  1149.          Close(Textfile);
  1150.          Close(SecondFile);
  1151.       end
  1152.       else begin
  1153.          GotoXY(1,8);
  1154.          write(chr(7),'New file already exists');
  1155.          Delay(1000);
  1156.       end;
  1157.    end
  1158.    else begin
  1159.       GotoXY(1,8);
  1160.       write(chr(7),'File does not exist');
  1161.       Delay(1000);
  1162.    end;
  1163. end;
  1164.  
  1165. procedure DosMenu;
  1166. var j, Inum : integer;
  1167.  
  1168. begin
  1169.    Inum := 1;
  1170.    Temp1 := Row;
  1171.    Temp2 := ScreenRow;
  1172.    Temp3 := Column;
  1173.    CommandWindow('     DOS Menu');
  1174.    GotoXY(1,5);
  1175.    writeln('1. Directory');
  1176.    writeln('2. Delete');
  1177.    writeln('3. Rename');
  1178.    writeln('4. Copy file');
  1179.    writeln('5. Exit to DOS');
  1180.    write('? ');
  1181.    read(Kbd, Choice);
  1182.    if ord(Choice)<>27 then begin
  1183.      Val(Choice, Num, code);
  1184.      case Num of
  1185.         1 : begin
  1186.               PrintDir;
  1187.               Inum := 3333;
  1188.             end;
  1189.         2 : DelFile;
  1190.         3 : RenFile;
  1191.         4 : CopyFile;
  1192.         5 : begin
  1193.               ClrScr;
  1194.               GotoXY(1,4);
  1195.               Writeln('Exit Turbo Script,');
  1196.               Writeln;
  1197.               Write('Erase memory (Y/N)? ');
  1198.               Read(Kbd, Choice);
  1199.               if (Choice = 'Y') or (Choice = 'y') then NumEnd := 9999
  1200.                   else NumEnd := 0;
  1201.             end;
  1202.      else
  1203.         write(chr(7));
  1204.      end;
  1205.      if Inum = 3333 then begin
  1206.         Row := 1;
  1207.         ScreenRow := 1;
  1208.         Column := 1;
  1209.         ClrScr;
  1210.         PrintWords;
  1211.      end;
  1212.    end;
  1213.    if Inum <> 3333 then begin
  1214.       Fill_In;
  1215.       Row := Temp1;
  1216.       ScreenRow := Temp2;
  1217.       Column := Temp3;
  1218.    end;
  1219. end;
  1220.  
  1221. procedure TabMenu;
  1222. Var Num, code : integer;
  1223.  
  1224. begin
  1225.    Temp1 := Row;
  1226.    Temp2 := ScreenRow;
  1227.    Temp3 := Column;
  1228.    CommandWindow('       Tab Menu');
  1229.    GotoXY(1,5);
  1230.    writeln('Enter Choice:');
  1231.    writeln;
  1232.    writeln('1.  Set');
  1233.    writeln('2.  Clear');
  1234.    writeln('3.  Purge');
  1235.    writeln;
  1236.    read(Kbd, Inkey);
  1237.    Val(Inkey, Num, code);
  1238.    if code = 0 then
  1239.      case Num of
  1240.        1 : Tabset[Column] := true;
  1241.        2 : Tabset[Column] := false;
  1242.        3 : for i := 1 to 79 do Tabset[i] := false;
  1243.      end
  1244.    else
  1245.      write(chr(7));
  1246.    Fill_In;
  1247.    Row := Temp1;
  1248.    ScreenRow := Temp2;
  1249.    Column := Temp3;
  1250. end;
  1251.  
  1252. procedure FuncPgUp;
  1253. var Diff : integer;
  1254.  
  1255. begin
  1256.    if Row >= 22 then begin
  1257.       Row := Row - 21;
  1258.       if ScreenRow > Row then ScreenRow := Row;
  1259.       ClrScr;
  1260.       GotoXY(1, ScreenRow);
  1261.       if ScreenRow = 22 then write(Words[Row]) else Writeln(Words[Row]);
  1262.       if (ScreenRow > 1) and (Row > 1) then begin
  1263.          GotoXY(1,1);
  1264.          for i := ScreenRow-1 downto 1 do writeln(Words[Row-i]);
  1265.          GotoXY(1,ScreenRow + 1);
  1266.          if ScreenRow < 22 then begin
  1267.             for i := ScreenRow + 1 to 21 do begin
  1268.                 if Words[Row+i-ScreenRow]=Test then writeln else
  1269.                     writeln(Words[Row+i-ScreenRow]);
  1270.             end;
  1271.             write(Words[Row+i-ScreenRow+1]);
  1272.          end
  1273.       end
  1274.       else if ScreenRow = 1 then begin
  1275.           GotoXY(1,2);
  1276.           for i := ScreenRow + 1 to 21 do begin
  1277.              if Words[Row+i-1]=Test then writeln else writeln(Words[Row+i-1]);
  1278.           end;
  1279.           write(Words[Row+i]);
  1280.       end
  1281.    end
  1282.    else begin
  1283.       if Row > ScreenRow then begin
  1284.          GotoXY(1,1);
  1285.          PrintWords
  1286.       end;
  1287.       Row := 1;
  1288.       ScreenRow := 1;
  1289.    end;
  1290. end;
  1291.  
  1292. procedure FuncPgDn;
  1293. var Diff : integer;
  1294.  
  1295. begin
  1296.    if Row + 21 < MaxRow then begin
  1297.       Row := Row + 21;
  1298.       Diff := ScreenRow;
  1299.       ClrScr;
  1300.       GotoXY(1,1);
  1301.       for i := 1 to 21 do begin
  1302.          if Words[Row-Diff+i] = Test then writeln else
  1303.              writeln(Words[Row-Diff+i]);
  1304.       end;
  1305.       write(Words[Row-Diff+i+1]);
  1306.    end;
  1307. end;
  1308.  
  1309. procedure DeleteLine;
  1310. begin
  1311.    DelLine;
  1312.    if MaxRow > Row + (23-ScreenRow) then begin
  1313.       GotoXY(1, 22);
  1314.       write(Words[Row+(23-ScreenRow)]);
  1315.    end;
  1316.    for i := Row to MaxRow + 1 do Words[i] := Words[i+1];
  1317.    MaxRow := MaxRow - 1;
  1318.    if Row > MaxRow then MaxRow := Row;
  1319. end;
  1320.  
  1321.  
  1322.  
  1323. procedure FuncEnd;
  1324. var ColTemp : integer;
  1325.     tchr : char;
  1326.  
  1327. begin
  1328.    ColTemp := 78;
  1329.    TempWord := Words[Row];
  1330.    repeat
  1331.       tchr := TempWord[ColTemp];
  1332.       ColTemp := ColTemp - 1;
  1333.    until tchr <> chr(32);
  1334.    Column := ColTemp + 2;
  1335. end;
  1336.  
  1337. procedure CtrlFuncEnd;
  1338. begin
  1339.    ClrEol;
  1340.    Words[Row] := Copy(Words[Row], 1, Column-1) + Replicate(79-Column+1, 32);
  1341. end;
  1342.  
  1343. procedure PrevWord;
  1344. var Temp : char;
  1345.    Count : integer;
  1346.  
  1347. begin
  1348.    TempWord := Words[Row];
  1349.    Count := Column - 1;
  1350.    if TempWord[Column] = ' ' then begin
  1351.       repeat
  1352.          Count := Count - 1;
  1353.          Temp := TempWord[Count];
  1354.       until Temp <> ' ';
  1355.    end;
  1356.    repeat
  1357.       Count := Count - 1;
  1358.       Temp := TempWord[Count];
  1359.    until (Temp = ' ') or (Count < 1);
  1360.    Column := Count + 1;
  1361.    if Column < 1 then Column := 1;
  1362. end;
  1363.  
  1364. procedure NextWord;
  1365. var Temp : char;
  1366.    Count : integer;
  1367.  
  1368. begin
  1369.    TempWord := Words[Row];
  1370.    Count := Column;
  1371.    if TempWord[Column] = ' ' then begin
  1372.       repeat
  1373.          Count := Count + 1;
  1374.          Temp := TempWord[Count];
  1375.       until Temp <> ' ';
  1376.       Column := Count;
  1377.    end
  1378.     else begin
  1379.       repeat
  1380.          Count := Count + 1;
  1381.          Temp := TempWord[Count];
  1382.       until (Temp = ' ') or (Count > 79);
  1383.       Column := Count + 1;
  1384.    end;
  1385.    if Column > 79 then Column := 79;
  1386. end;
  1387.  
  1388. procedure Tab;
  1389. begin
  1390.    if Column < 79 then begin
  1391.       repeat
  1392.         Column := Column + 1;
  1393.       until (Tabset[Column] = true) or (Column = 79);
  1394.    end;
  1395. end;
  1396.  
  1397. procedure BackTab;
  1398. begin
  1399.    if Column > 1 then begin
  1400.       repeat
  1401.          Column := Column - 1;
  1402.       until (Tabset[Column] = true) or (Column = 1);
  1403.    end;
  1404. end;
  1405.  
  1406. procedure Help;
  1407. var Count : integer;
  1408.  
  1409. begin
  1410.    Assign(TextFile, 'HELP.HLP');
  1411.    Reset(TextFile);
  1412.    While EOF(Textfile) = false do begin
  1413.       ClrScr;
  1414.       GotoXY(1,1);
  1415.       Count := 0;
  1416.       NormVideo;
  1417.       repeat
  1418.          Readln(TextFile, TempWord);
  1419.          Count := Count + 1;
  1420.          writeln(TempWord);
  1421.       until Count = 20;
  1422.       LowVideo;
  1423.       GotoXY(1,22);
  1424.       Write('      < Press');
  1425.       NormVideo;
  1426.       Write(' ENTER ');
  1427.       LowVideo;
  1428.       Write('to continue >');
  1429.       read(Kbd, Choice);
  1430.    end;
  1431.    Close(TextFile);
  1432.    NormVideo;
  1433.    MaxRow := Row + 1;
  1434.    Row := 1;
  1435.    Column := 1;
  1436.    ScreenRow := 1;
  1437.    ClrScr;
  1438.    GotoXY(1,1);
  1439.    PrintWords;
  1440. end;
  1441.  
  1442. procedure Ascii;
  1443. var Ascnum, Repeats, r : integer;
  1444.  
  1445. begin
  1446.    Window(1,1,80,25);
  1447.    GotoXY(1,1);
  1448.    Write('Enter ASCII code number: --- ');
  1449.    GotoXY(26,1);
  1450.    Read(Ascnum);
  1451.    GotoXY(1,1);
  1452.    Write('Enter number of repeats: --  ');
  1453.    GotoXY(26,1);
  1454.    Read(Repeats);
  1455.    GotoXY(1,1);
  1456.    Write(Replicate(30,205));
  1457.    GotoXY(16,1);
  1458.    Write('Turbo Script');
  1459.    Window(1,2,80,23);
  1460.    If (Ascnum < 255) and (Repeats < 79) then begin
  1461.       for r := 1 to Repeats do begin
  1462.          GotoXY(Column,ScreenRow);
  1463.          Inkey := chr(Ascnum);
  1464.          Character;
  1465.       end;
  1466.    end
  1467.     else write(chr(7));
  1468. end;
  1469.  
  1470. procedure Esc;
  1471. begin
  1472.    Column := 1;
  1473.    GotoXY(1, WhereY);
  1474.    ClrEol;
  1475.    Words[Row] := Replicate(79,32);
  1476. end;
  1477.  
  1478. procedure BeginFile;
  1479. begin
  1480.    GotoXY(1,1);
  1481.    if Row > ScreenRow then begin
  1482.       ClrScr;
  1483.       PrintWords;
  1484.    end;
  1485.    Row := 1;
  1486.    Column := 1;
  1487.    ScreenRow := 1;
  1488. end;
  1489.  
  1490. procedure EndFile;
  1491. begin
  1492.    Row := MaxRow + 1;
  1493.    ScreenRow := 12;
  1494.    Column := 1;
  1495.    Temp1 := Row-11;
  1496.    ClrScr;
  1497.    GotoXY(1,1);
  1498.    for i := 0 to 20 do begin
  1499.       if Words[Temp1 + i] = Test then writeln else
  1500.            writeln(Words[Temp1 + i]);
  1501.    end;
  1502.    write(Words[Temp1 + 21]);
  1503. end;
  1504.  
  1505. procedure Title;
  1506. begin
  1507.   Column := 1;
  1508.   Words[Row] := 'Title' + Replicate(75,32);
  1509.   GotoXY(Column, Row);
  1510.   Writeln(Words[Row]);
  1511.   Row := Row + 1;
  1512.   if Row > MaxRow then MaxRow := Row;
  1513.   ScreenRow := ScreenRow + 1;
  1514. end;
  1515.  
  1516. procedure HandleFunc;
  1517.   begin
  1518.      case Keynum of
  1519.         8 : Backspace;
  1520.         9 : Tab;
  1521.        13 : Enter;
  1522.        15 : Backtab;
  1523.        23 : begin
  1524.                if Italicmode then begin
  1525.                   Inkey := chr(175);
  1526.                   Italicmode := false;
  1527.                end
  1528.                 else begin
  1529.                   Inkey := chr(174);
  1530.                   Italicmode := true
  1531.                end;
  1532.                Character;
  1533.             end;
  1534.        27 : Esc;
  1535.        30 : Ascii;
  1536.        48 : begin
  1537.                if Boldmode then begin
  1538.                   Inkey := chr(221);
  1539.                   Boldmode := false;
  1540.                end
  1541.                 else begin
  1542.                   Inkey := chr(222);
  1543.                   Boldmode := true;
  1544.                end;
  1545.                Character;
  1546.             end;
  1547.        59 : Help;
  1548.        60 : Menu_S_R;
  1549.        61 : TabMenu;
  1550.        62 : Title;
  1551.        63 : DosMenu;
  1552.        64 : Insertline;
  1553.        65 : Deleteline;
  1554.        66 : Printfile;
  1555.        67 : Loadfile;
  1556.        68 : Savefile;
  1557.        71 : Column := 1;
  1558.        72 : CursorUp;
  1559.        73 : FuncPgUp;
  1560.        75 : CursorLeft;
  1561.        77 : CursorRight;
  1562.        79 : FuncEnd;
  1563.        80 : CursorDown;
  1564.        81 : FuncPgDn;
  1565.        82 : Ins;
  1566.        83 : Del;
  1567.       115 : PrevWord;
  1568.       116 : NextWord;
  1569.       117 : CtrlFuncEnd;
  1570.       118 : EndFile;
  1571.       119 : begin
  1572.                ClearScreen;
  1573.                Fill_In;
  1574.                if Exit = false then begin
  1575.                   ClrScr;
  1576.                   ScreenRow := 1;
  1577.                end;
  1578.             end;
  1579.       132 : BeginFile;
  1580.     else
  1581.       Sound(200);
  1582.       Delay(300);
  1583.       NoSound;
  1584.     end;
  1585.   end;
  1586.  
  1587. begin
  1588.   Initialize;
  1589.   PrintRow;
  1590.   repeat
  1591.     Secnum := false;
  1592.     if Getkey(Secnum, Inkey) then begin
  1593.        if Secnum then HandleFunc else Character;
  1594.        PrintRow;
  1595.        Exit := false;
  1596.        if Length(Words[Row]) > 79 then Words[Row] := Copy(Words[Row], 1, 79);
  1597.        if Insertmode then begin
  1598.          GotoXY(1, ScreenRow);
  1599.          if ScreenRow = 22 then write(Words[Row]) else writeln(Words[Row]);
  1600.        end;
  1601.        GotoXY(Column , ScreenRow);
  1602.     end;
  1603.     if IOresult <> 0 then NumEnd := 9999;
  1604.   until NumEnd = 9999;
  1605.   Window(1,1,80,25);
  1606.   ClrScr;
  1607. end.
  1608.